package com.chinasoft.maysham.manager.controller.cluster;

import com.chinasoft.maysham.manager.controller.BaseController;
import com.chinasoft.maysham.manager.model.Cluster;
import com.chinasoft.maysham.manager.request.ClusterCreateReq;
import com.chinasoft.maysham.manager.service.cluster.ClusterService;
import org.springframework.web.bind.annotation.*;

import javax.annotation.Resource;
import java.util.List;

@RestController
@RequestMapping("/clusters")
public class ClusterController extends BaseController {

    @Resource
    private ClusterService clusterService;


    @PostMapping("/create")
    public Cluster create(@RequestBody ClusterCreateReq createReq) {
        return clusterService.create(createReq);
    }

    @GetMapping("/list")
    public List<Cluster> list(@RequestParam(defaultValue = "0", required = false) int page,
                              @RequestParam(defaultValue = "10", required = false) int size) {
        return clusterService.list(page,size);
    }

    @DeleteMapping("/{clusterId}/delete")
    public boolean delete(@PathVariable String clusterId) {
        return clusterService.delete(clusterId);
    }
}
